package com.siyu.basedata.pptnrsence.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.siyu.common.core.controller.BaseController;
import com.siyu.common.core.domain.AjaxResult;
import com.siyu.common.core.page.TableDataInfo;
import com.siyu.common.utils.poi.ExcelUtil;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.siyu.basedata.pptnrsence.domain.PptnRSence;
import com.siyu.basedata.pptnrsence.service.IPptnRSenceService;

/**
 * 情景降雨数据Controller
 *
 * @author hrhy
 * @date 2024-07-04
 */
@RestController
@RequestMapping("/basedata/PptnRSence")
public class PptnRSenceController extends BaseController {
    @Autowired
    private IPptnRSenceService pptnRSenceService;

    /**
     * 查询情景降雨数据列表
     */
    @GetMapping("/list")
    public TableDataInfo list(PptnRSence pptnRSence) {
        startPage();
        List<PptnRSence> list = pptnRSenceService.selectPptnRSenceList(pptnRSence);
        return getDataTable(list);
    }

    /**
     * 导出情景降雨数据列表
     */
    @PostMapping("/export")
    public void export(HttpServletResponse response, PptnRSence pptnRSence) {
        List<PptnRSence> list = pptnRSenceService.selectPptnRSenceList(pptnRSence);
        ExcelUtil<PptnRSence> util = new ExcelUtil<PptnRSence>(PptnRSence.class);
        util.exportExcel(response, list, "情景降雨数据数据");
    }

    /**
     * 获取情景降雨数据详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id) {
        return success(pptnRSenceService.selectPptnRSenceById(id));
    }

    /**
     * 新增情景降雨数据
     */
    @PostMapping
    public AjaxResult add(@RequestBody PptnRSence pptnRSence) {
        return toAjax(pptnRSenceService.insertPptnRSence(pptnRSence));
    }

    /**
     * 修改情景降雨数据
     */
    @PutMapping
    public AjaxResult edit(@RequestBody PptnRSence pptnRSence) {
        return toAjax(pptnRSenceService.updatePptnRSence(pptnRSence));
    }

    /**
     * 删除情景降雨数据
     */
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids) {
        return toAjax(pptnRSenceService.deletePptnRSenceByIds(ids));
    }
}
